package com.weiyuwqj.admin.controller.admin.user;

import com.weiyuwqj.api.service.BusUserSuggestionService;
import com.weiyuwqj.api.common.Paginator;
import com.weiyuwqj.api.constant.Message;
import com.weiyuwqj.api.model.BusUserSuggestion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by lips on 2016/2/2.
 */
@Controller
@RequestMapping(value="/admin/userSuggestion")
public class BusUserSuggestionController {

    @Autowired
    BusUserSuggestionService busUserSuggestionService;

    @RequestMapping(value="/getOne", method = RequestMethod.POST)
    public Object getOne(int id){
        return busUserSuggestionService.selectByKey(id);
    }

    @ResponseBody
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public Object add(BusUserSuggestion busUserSuggestion){
        busUserSuggestion.setAddtime(new Date());
        busUserSuggestionService.save(busUserSuggestion);;
        return Message.OK;
    }

    @ResponseBody
    @RequestMapping(value="/list", method = RequestMethod.POST)
    public Object getList(@ModelAttribute Paginator p,HttpServletRequest request){
        String contact = request.getParameter("contact");
        String beginDateTime = request.getParameter("beginDateTime");
        String endDateTime = request.getParameter("endDateTime");
        Map map=new HashMap();
        map.put("contact",contact);
        map.put("beginDateTime",beginDateTime);
        map.put("endDateTime",endDateTime);
        return busUserSuggestionService.getList(p,map);
    }

}
